﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Example04.aspx.cs" Inherits="Chapter27.Example04" %>

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>代码清单 27-4 对用户进行提示</title>
    <meta name="author" content="Adam Freeman" />
    <meta name="description" content="A simple example" />
    <style>
        table {
            border-collapse: collapse;
            border: thin solid black;
        }

        th, td {
            padding: 4px;
        }
    </style>
</head>
<body id="bod">
    <p>
        <button id="alert">Alert</button>
        <button id="confirm">Confirm</button>
        <button id="prompt">Prompt</button>
        <button id="modal">Model Dialog</button>
    </p>
    <script>
        var buttons = document.getElementsByTagName("button");
        for (var i = 0; i < buttons.length; i++) {
            buttons[i].onclick = handleButtonPress;
        }
        function handleButtonPress(e) {
            if (e.target.id == "alert") {
                window.alert("This is an alert");
            } else if (e.target.id == "confirm") {
                var confirmed = window.confirm("This is confirm - do you want to proceed?");
                alert("Confirmed? " + confirm);
            } else if (e.target.id == "prompt") {
                var response = window.prompt("Enter a word", "hello");
                alert("The word was " + response);
            } else if (e.target.id == "modal") {
                window.showModalDialog("http://apress.com");

            }
        }
    </script>
</body>
</html>
